<?php

Yii::import('application.models._base.BaseProfiles');

class Profiles extends BaseProfiles
{
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
        public function rules() {
		return array(
			array('firstname, email', 'required'),
			array('user_id', 'numerical', 'integerOnly'=>true),
			array('firstname, lastname', 'length', 'max'=>50),
			array('contact_number, address2, state, logo', 'length', 'max'=>45),
			array('email, street', 'length', 'max'=>255),
			array('zip', 'length', 'max'=>10),
			array('privacy', 'length', 'max'=>9),
			array('about, modified_at', 'safe'),
			array('firstname, lastname, about, contact_number, email, street, address2, state, zip, modified_at', 'default', 'setOnEmpty' => true, 'value' => null),
			array('profile_id, user_id, firstname, lastname, about, contact_number, email, street, address2, state, zip, logo, created_at, modified_at, privacy', 'safe', 'on'=>'search'),
		);
	}
        public function setProfile($attributes) {

        $this->setAttribute('created_at', time());
        $this->setAttribute('firstname', $attributes['firstname']);
        $this->setAttribute('lastname', $attributes['lastname']);
        $this->setAttribute('email', $attributes['email']);
        return $this;
    }
}